package com.younion.dao;

import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.younion.common.base.BaseDAO;
import com.younion.common.base.BaseVO;
import com.younion.common.exception.BaseException;
import com.younion.common.paginator.Paginator;
import com.younion.vo.OperateLogVO;

public class OperateLogDAO extends BaseDAO {
	
	protected static final Log logger = LogFactory.getLog(OperateLogDAO.class);
	
	 
	public int selectCountByMap(Map paramMap) throws BaseException {
		if (paramMap == null)
			return 0;
		try {
			return queryCount("t_operate_log.selectByMapCount", paramMap);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new BaseException(this.getClass().getSimpleName() +" method error");
		}
	}

	 
	public List selectForPage(Map condition, Paginator paginator) throws BaseException {
		if (condition == null)
			return null;
		int pageIndex = paginator.getStartIndex();
		int perPageSize = paginator.getPageSize();
		String sqlStr = "";
		try {
			Map vo = (Map) condition.get("paramMap");
			if (vo == null) {
				sqlStr = "t_operate_log.selectAll";
			} else {
				sqlStr = "t_operate_log.selectByMap";
			}
			return queryForPage(sqlStr, vo, pageIndex, perPageSize);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new BaseException(this.getClass().getSimpleName() +" method error");
		}
	}

	 
	public OperateLogVO insertByVo(OperateLogVO operateLogVO) throws BaseException {
		if (operateLogVO == null)
			return null;
		try {
			return (OperateLogVO) this.insert("t_operate_log.insertByVo", (BaseVO) operateLogVO);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new BaseException(this.getClass().getSimpleName() +" method error");
		}
	}

}
